<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>${'$'}{SYSTEM_NAME}</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="${'$'}{pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${'$'}{FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${'$'}{pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${'$'}{FILE_VERSION}" media="all">
</head>
<body>
	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-card-header">${generatorTable.tableComment}</div>
			<div class="layui-card-body">
				<#if generatorTable.hasQuery gt 0>
					<div class="layui-form layer-query">
						<div class="layui-form-item">
							<#if generatorTable.fieldList?exists && generatorTable.fieldList?size gt 0>
								<#list generatorTable.fieldList as fieldItem >
									<#if fieldItem.isQuery =='1'>
										<#if (fieldItem.inputType =='1' || fieldItem.inputType =='2') >
								<div class="layui-inline">
									<label class="layui-form-label">${fieldItem.columnComment!""}：</label>
									<div class="layui-input-inline">
										<input type="text" id="${fieldItem.fieldName}" class="layui-input">
									</div>
								</div>

										</#if>
										<#if fieldItem.inputType =='3'>
								<div class="layui-inline">
									<label class="layui-form-label">${fieldItem.columnComment!""}：</label>
									<div class="layui-input-inline">
										<input type="text" id="${fieldItem.fieldName}" placeholder="点击选择${fieldItem.columnComment!""}"
											   class="layui-input" readonly="readonly" />
									</div>
								</div>

										</#if>
										<#if fieldItem.inputType =='6'>
								<div class="layui-inline">
									<label class="layui-form-label">${fieldItem.columnComment!""}：</label>
									<div class="layui-input-inline">
										<select id="${fieldItem.fieldName}">
											<option value="">请选择${fieldItem.columnComment!""}</option>
											<c:forEach items="${'$'}{${fieldItem.paramName}_MAP}" var="t">
												<option value="${'$'}{t.key }">${'$'}{t.value }</option>
											</c:forEach>
										</select>
									</div>
								</div>
										</#if>
									</#if>
								</#list>
							</#if>
							<div class="layui-inline">
								<button class="layui-btn layui-btn-primary layui-border-blue" onclick="reload()">查询</button>
							</div>
						</div>
					</div>
					<hr class="layui-bg-green">
				</#if>

				<table class="layui-table" lay-filter="tableId" id="layerTable">
				</table>
			</div>
		</div>
	</div>
	<script type="text/html" id="barTpl">
  		<a class="layui-btn layui-btn-xs layui-btn-primary layui-bg-orange" lay-event="select">选择</a>
	</script>
	<script src="${'$'}{pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${'$'}{FILE_VERSION}"></script>
	<script src="${'$'}{pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${'$'}{FILE_VERSION}"></script>
	<script src="${'$'}{pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${'$'}{FILE_VERSION}"></script>
	<script>
		var table;
		layui.use(['table','laydate'], function(){
		  table = layui.table;
			<#if generatorTable.inputTypes?contains("3")>
			var laydate = layui.laydate;
				<#if generatorTable.fieldList?exists && generatorTable.fieldList?size gt 0>
					<#list generatorTable.fieldList as fieldItem >
						<#if fieldItem.inputType =='3' && fieldItem.isQuery =='1'>
			laydate.render({
				elem: '#${fieldItem.fieldName}'
				,type: 'date'
				,range: false
			});
						</#if>
					</#list>
				</#if>
			</#if>

		  table.render({ //其它参数在此省略
			  elem : '#layerTable',
			  even :"true",
			  limit: 10,
			  limits: [10,20,30],
			  id: 'tableId',
			  url: getContextPath() + '/${generatorTable.moudleName}/${generatorTable.shiro}/list/listInfo',
			  page:true,
			  method: 'post', //如果无需自定义HTTP类型，可不加该参数
			  cols:  [[ //标题栏
                  {fixed: true,width:120, align:'center',title:"操作", toolbar: '#barTpl'}
				  <#if generatorTable.fieldList?exists && generatorTable.fieldList?size gt 0>
					  <#list generatorTable.fieldList as fieldItem >
						  <#if fieldItem.listShow !='0'>
						  	<#if fieldItem.inputType =='3'>
				  ,{field : '${fieldItem.fieldName}',width : 180, title : '${fieldItem.columnComment!""}',templet : '<div>{{layui.util.toDateString(d.${fieldItem.fieldName}, "yyyy-MM-dd")}}</div>'}
				  			<#else>
				  ,{field : '${fieldItem.fieldName}<#if fieldItem.paramName?exists && fieldItem.paramName?length gt 0>Name</#if>',width : 120,sort : true,title : '${fieldItem.columnComment!""}'}
						  	</#if>
						  </#if>
					  </#list>
				  </#if>
				 ,{fixed: 'right', width:120, align:'center',title:"操作", toolbar: '#barTpl'}
			   ]],
			  request: {
				  pageName: 'current', //页码的参数名称，默认：page
				  limitName: 'size' //每页数据量的参数名，默认：limit
			  } //如果无需自定义请求参数，可不加该参数
			});

			//监听工具条
			table.on('tool(tableId)', function(obj){
				var data = obj.data;
                if(obj.event === 'select'){
                    parent.selectValue(data.id, data.name);
				}
			});
		});

		function reload() {
			table.reload('tableId'<#if generatorTable.hasQuery gt 0>,{
				where :{
					"t":""
					<#if generatorTable.fieldList?exists && generatorTable.fieldList?size gt 0>
					<#list generatorTable.fieldList as fieldItem >
					<#if fieldItem.isQuery =='1' && (fieldItem.inputType =='1' || fieldItem.inputType =='2'
                        || fieldItem.inputType =='3' || fieldItem.inputType =='6' )>
					,"${fieldItem.fieldName}": ${'$'}("#${fieldItem.fieldName}").val()
					</#if>
					</#list>
					</#if>
				}
				</#if>
			});
		}

	</script>
</body>
</html>